/************************************************************
 * Copyright (C), 2022-2030, ripnano. Co., Ltd.
 * FileName:        form_setting_network.h
 * Author:          Dan Yin
 * Date:            2023-10-23
 * Description:     the class of network setting window
 * Version:         1.0.0.0
 **********************************************************/

#ifndef FORM_SETTING_NETWORK_H
#define FORM_SETTING_NETWORK_H

// add necessary includes here
#include "ui/defines/global.h"
#include "utils/configure/i_configure_bll.h"

namespace Ui {
class FormSettingNetwork;
}

class FormSettingNetwork : public QWidget
{
    Q_OBJECT

public:
    // Get an instance of "FormSettingNetwork" class, if exist, return it
    static FormSettingNetwork* getInstance(QWidget *pParent = nullptr);

signals:
    // The signal that refresh UI info
    void signalRefreshUI();

    // Switch the language(English/Chinese)
    void signalSwitchLanguage(int eumLangType);

private slots:
    // The slot that refresh UI info
    void slotRefreshUI();

    // Ping to specify the IP
    void on_pushButton_Ping_clicked();

    // Ping The specified port number for the specified IP
    void on_pushButton_PingEx_clicked();

protected:
    // Triggers an event before it is switch language
    void changeEvent(QEvent *event);

    // Triggers an event the hide the window
    void hideEvent(QHideEvent *event);

private:
    // The default constructor
    explicit FormSettingNetwork(QWidget *parent = nullptr);

    // The default destructor
    virtual ~FormSettingNetwork();

    // After constructing object, initialize the object
    void _initialze();

    // Init the window style
    void _initUi();

    // Refresh the network info
    void _refreshNetworkUI(ST_CFG_NETWORK stNetwork);

    // Load the local IP info from config file & display
    void _refreshLocalInfo(ST_CFG_NETWORK stNetwork);

    // Load the remote IP & port from config file & display
    void _refreshServerInfo(ST_CFG_NETWORK stNetwork);

    // Save the network info
    void _saveNetworkInfo();

    // Clear the text of static/dynamic ip
    void _clearIpText(bool bDynamicIP);

private:
    Ui::FormSettingNetwork *ui;
};

#endif // FORM_SETTING_NETWORK_H
